<?php

namespace App\Http\Controllers\Mobile\Personal;
use App\Models\Personal\SearchEngine;
use Style;

class SearchEngineController extends CommonController{

    /**
     * 搜索器资源控制器列表
     * @return mixed
     */
    public function index(){
        $user = auth()->guard('personal')->user();
        $searchEngine = SearchEngine::where('uid',$user->uid)->orderBy('updated_at','desc')->paginate(10);
        foreach($searchEngine as $k=> $v ){
            $alinks = arrayFilter(array(
                "jobsort1" => !empty($v->jobsort1) ? $v->jobsort1 : '',
                "jobsort2" => !empty($v->jobsort2) ? $v->jobsort2 : '',
                "jobsort3" => !empty($v->jobsort3) ? $v->jobsort3 : '',
                "jobsort4" => !empty($v->jobsort4) ? $v->jobsort4 : '',
                "jobsort5" => !empty($v->jobsort5) ? $v->jobsort5 : '',
                "jobarea1" => !empty($v->jobarea1) ? $v->jobarea1 : '',
                "jobarea2" => !empty($v->jobarea2) ? $v->jobarea2 : '',
                "jobarea3" => !empty($v->jobarea3) ? $v->jobarea3 : '',
                "jobarea4" => !empty($v->jobarea4) ? $v->jobarea4 : '',
                "jobarea5" => !empty($v->jobarea5) ? $v->jobarea5 : '',
                "industry1" => !empty($v->industry1) ? $v->industry1 : '',
                "industry2" => !empty($v->industry2) ? $v->industry2 : '',
                "industry3" => !empty($v->industry3) ? $v->industry3 : '',
                "industry4" => !empty($v->industry4) ? $v->industry4 : '',
                "industry5" => !empty($v->industry5) ? $v->industry5 : '',
                "sex" => !empty($v->sex) ? $v->sex : '',
                "age" => !empty($v->age) ? $v->age : '',
                "education" => !empty($v->education) ? $v->education : '',
                "work_year" => !empty($v->work_year) ? $v->work_year : '',
                "keyword" => !empty($v->keyword) ? $v->keyword : '',
                "keyword_type" => !empty($v->keyword_type) ? $v->keyword_type : '',
                "release_date" => !empty($v->release_date) ? $v->release_date : '',
            ));
            //设置a连接属性
            $search = '';
            foreach($alinks as $kk => $vv){
                $search .= $kk . '=' . $vv .'&';
            }
            $search = '?'.trim($search,'&');
            $v->search_link = asset('mobile/job'.$search);
        }
        return Style::view('mobile.personal.searchIndex',compact('searchEngine'));
    }
}